// pages/my/index.js
var utils = require('../../utils/utils.js');
var app = getApp();
var id="";
Page({
  data: {
    // 用户信息
    userInfo: {
      avatarUrl: "",
    },

  },
  // 页面加载
  onLoad: function () {
    // this.getMarker();
    // 获取本地数据-用户信息
    var info=wx.getStorageSync('info')
    this.setData({ userInfo: info});
  },
  toDetailsTap: function (e) {
    id=e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/pages/bookDetail/bookDetail?id='+id,
    })
  },
  // 获取图书信息
  getMarker: function () {
    var that = this;
    var GETJWT = wx.getStorageSync('JWT');
    wx.request({
      // url:'http://123.207.164.181:8080/ke/userinfo/getmyBook',
      url: 'https://weixiaoguo1990.com/ke/userinfo/getmyBook',
      // url: "http://oldke.ngrok.cc/userinfo/getmyBook",
      method: 'POST',
      header: {
        JWT: GETJWT,
        'content-type': 'application/json'
      }, // 设置请求的 header
      success: (res) => {
        console.log(res.data);
        that.setData({ recommend: res.data.data })
      },
      fail: function (res) {
        // fail
      },
      complete: function (res) {
        // complete
      }
    })
  },
  getDeleteN:function(e){
    console.log(e);
    
  },
  // 删除某本图书
  getDelete: function (e) {
    var id = e.currentTarget.dataset.id;
    var that = this;
    var param = {
      bookid: id,
    }
    var GETJWT = wx.getStorageSync('JWT');
    wx.request({
      // url:'http://123.207.164.181:8080/ke/userinfo/delmyBook',
      url: 'https://weixiaoguo1990.com/ke/userinfo/delmyBook',
      // url: "http://oldke.ngrok.cc/userinfo/delmyBook",
      method: 'POST',
      data: param,
      header: {
        JWT: GETJWT,
        'content-type': 'application/json'
      }, // 设置请求的 header
      success: (res) => {
        console.log(res.data);
        that.getMarker();
      },
      fail: function (res) {
        // fail
      },
      complete: function (res) {
        // complete
      }
    })
  },
  
 
 
})